package net.ermannofranco.genericdaojdbc.clause;

import net.ermannofranco.genericdaojdbc.util.Comparation;

public class ComparationClause extends OneClause {
	private final Comparation comp;
	private final Object value;

	protected ComparationClause(String propName, Comparation comp, Object value) {
		super(propName);
		if (comp == null)
			throw new IllegalArgumentException("comparation nullo!!!");
		if (value == null)
			throw new IllegalArgumentException(
					"valore null, usare NullityClause");
		this.comp = comp;
		this.value = value;
	}

	protected ComparationClause(String propName, Object value) {
		this(propName, Comparation.EQUAL, value);
	}

	@Override
	public final String getDiscriminator() {
		return comp.val();
	}

	@Override
	public final boolean requiresNamedParam() {
		return true;
	}

	public final Object getValue() {
		return value;
	}

}
